package com.lms.nio.channel;

import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.OpenOption;
import java.nio.file.Paths;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-05-06 07:54
 * @Description: ${Description}
 */
public class FileChannel02 {
    public static void main(String[] args) throws Exception {
        FileInputStream fis = new FileInputStream("W:\\学习笔记\\demo.txt");
        FileOutputStream fos = new FileOutputStream("W:\\学习笔记\\demo3.txt");
        FileChannel fosChannel = fos.getChannel();
        FileChannel fisChannel = fis.getChannel();

        long l = fisChannel.transferTo(0, fisChannel.size(), fosChannel);
        System.out.println(l);
        FileOutputStream fos2 = new FileOutputStream("W:\\学习笔记\\demo4.txt",true);
        FileChannel fosChannel2 = fos2.getChannel();
        long l1 = fosChannel2.transferFrom(fisChannel, 0, fisChannel.size());
        System.out.println(l1);


    }
}
